package com.sip.stream.activity.preview.model;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.SurfaceTexture;
import android.hardware.camera2.CameraManager;
import android.hardware.usb.UsbDevice;
import android.media.AudioManager;
import android.os.Build;
import android.util.Log;

import com.serenegiant.usb.USBMonitor;
import com.sip.stream.ClientApp;
import com.sip.stream.R;
import com.sip.stream.helper.ZFYUsbDeviceHelper;
import com.sip.stream.media.ZFYCameraParameters;
import com.sip.stream.media.ZFYMediaManager;
import com.sip.stream.rxbus.RxBus;
import com.sip.stream.utils.zfy.camera.AbstractZFYCamera;
import com.sip.stream.utils.zfy.camera.UVCCameraHelper;
import com.sip.stream.utils.zfy.camera.ZFYCamera1Helper;
import com.sip.stream.utils.zfy.RxBusTag;
import com.sip.stream.utils.zfy.ZFYCameraCallBack;
import com.sip.stream.utils.zfy.status.ZFYStatus;

import io.reactivex.Observable;
import io.reactivex.Observer;
import io.reactivex.Single;
import io.reactivex.SingleObserver;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Action;
import io.reactivex.functions.BiFunction;
import io.reactivex.functions.Consumer;
import io.reactivex.functions.Function;
import io.reactivex.subjects.PublishSubject;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import kotlinx.coroutines.DebugKt;

public class CameraViewModel {
    private static final String TAG = "CameraViewModel";
    private AbstractZFYCamera camera;
    private ZFYCameraCallBack cameraCallBack;
    private AtomicBoolean captureLock;
    private CompositeDisposable compositeDisposable;
    private Context context;
    private BroadcastReceiver flashLightBroadcastReceiver;
    private boolean isFront;
    private boolean isQRScan;
    private PublishSubject<Integer> statueChangePublishSubject;
    private float targetZoom;
    private boolean userPreviewSurface;
    private AtomicBoolean zoomLock;


    public static  AbstractZFYCamera lambda$setUpCamera2$3(AbstractZFYCamera abstractZFYCamera, ZFYCameraParameters cameraParameters) throws Exception {
        return abstractZFYCamera;
    }

    public void setFront(boolean isFront) {
        this.isFront = isFront;
    }

    public boolean isUserPreviewSurface() {
        return this.userPreviewSurface;
    }

    public void setUserPreviewSurface(boolean userPreviewSurface) {
        this.userPreviewSurface = userPreviewSurface;
    }

    public boolean useEGLPreviewSurface() {
        return isUserPreviewSurface() && !(this.camera instanceof UVCCameraHelper);
    }

    private CameraViewModel() {
        this.isQRScan = false;
        this.isFront = false;
        this.userPreviewSurface = false;
        this.statueChangePublishSubject = PublishSubject.create();
        this.camera = null;
        this.cameraCallBack = null;
        this.captureLock = new AtomicBoolean();
        this.zoomLock = new AtomicBoolean(false);
        this.targetZoom = 1.0f;
        this.compositeDisposable = null;
    }

    protected CameraViewModel(Context context) {
        this.isQRScan = false;
        this.isFront = false;
        this.userPreviewSurface = false;
        this.statueChangePublishSubject = PublishSubject.create();
        this.camera = null;
        this.cameraCallBack = null;
        this.captureLock = new AtomicBoolean();
        this.zoomLock = new AtomicBoolean(false);
        this.targetZoom = 1.0f;
        this.compositeDisposable = null;
        this.context = context;
    }

    public CameraViewModel(Context context, ZFYCameraCallBack zFYCameraCallBack) {
        this.isQRScan = false;
        this.isFront = false;
        this.userPreviewSurface = false;
        this.statueChangePublishSubject = PublishSubject.create();
        this.camera = null;
        this.cameraCallBack = null;
        this.captureLock = new AtomicBoolean();
        this.zoomLock = new AtomicBoolean(false);
        this.targetZoom = 1.0f;
        this.compositeDisposable = null;
        this.context = context;
        this.cameraCallBack = zFYCameraCallBack;
        subscribeEvent();
    }

    public CameraViewModel(Context context, ZFYCameraCallBack zFYCameraCallBack, boolean isQRScan) {
        this.isQRScan = false;
        this.isFront = false;
        this.userPreviewSurface = false;
        this.statueChangePublishSubject = PublishSubject.create();
        this.camera = null;
        this.cameraCallBack = null;
        this.captureLock = new AtomicBoolean();
        this.zoomLock = new AtomicBoolean(false);
        this.targetZoom = 1.0f;
        this.compositeDisposable = null;
        this.context = context;
        this.cameraCallBack = zFYCameraCallBack;
        this.isQRScan = isQRScan;
    }

    public Context getContext() {
        return this.context;
    }

    public Single<ZFYCameraParameters> setUpCamera() {
        Log.i(TAG, "setUpCamera");
        this.zoomLock.set(false);
        this.targetZoom = 1.0f;
        setUpReceiver();
        Log.i(TAG, "start closeOpenedCamera");
        return closeOpenedCamera().flatMap(new Function() {
            @Override
            public  Object apply(Object obj) {
                if (ZFYStatus.getInstance().isUVCCameraIn()) {
                    return setupUVCCamera();
                }

                //Camera1
                return setUpCamera1();
            }
        }).map(new Function() {
            @Override
            public  Object apply(Object obj) {
                AbstractZFYCamera abstractZFYCamera = (AbstractZFYCamera) obj;
                CameraViewModel.this.camera = abstractZFYCamera;
                return abstractZFYCamera.getParameters();
            }
        });
    }


    /***
     * Camera1 初始化
     * @return
     */
    private Single<AbstractZFYCamera> setUpCamera1() {
        Log.i(TAG, "setUpCamera1");
        ZFYCamera1Helper zFYCamera1Helper = new ZFYCamera1Helper(ClientApp.clientApp.getApplicationContext(), isTorchOpen() ? 1 : 2);
        zFYCamera1Helper.setInfraredLightMode(false);
        zFYCamera1Helper.setHdr(ZFYMediaManager.getInstance().getConfig().isHdr());
        zFYCamera1Helper.setStabilization(ZFYMediaManager.getInstance().getConfig().isImageStablization());
        zFYCamera1Helper.setCameraCallBack(getCameraCallBack());
        zFYCamera1Helper.setQRScan(this.isQRScan);
        zFYCamera1Helper.setFrontSide(this.isFront);
        return Single.zip(Single.just(zFYCamera1Helper), zFYCamera1Helper.setUp(), new BiFunction() {
            @Override
            public  Object apply(Object obj, Object obj2) {
                ZFYCamera1Helper zfyCamera1Helper = (ZFYCamera1Helper) obj;
                return zfyCamera1Helper;
            }
        });
    }


    private Single<AbstractZFYCamera> setupUVCCamera() {
        Log.i(TAG, "setupUVCCamera");
        UVCCameraHelper uVCCameraHelper = new UVCCameraHelper(getContext());
        uVCCameraHelper.setCameraCallBack(getCameraCallBack());
        return Single.zip(Single.just(uVCCameraHelper), uVCCameraHelper.setUp(), new BiFunction() {
            @Override
            public Object apply(Object obj, Object obj2) {
                UVCCameraHelper uvcCameraHelper = (UVCCameraHelper) obj2;
                return uvcCameraHelper;
            }
        });
    }

    private Single<Boolean> closeOpenedCamera() {
        if (this.camera == null) {
            Log.i(TAG, "closeOpenedCamera camera == null");
            return Single.just(Boolean.FALSE);
        }
        Log.i(TAG, "closeOpenedCamera " + this.camera.getLocalizedName());
        return this.camera.closeCamera().doOnSuccess(new Consumer<Boolean>() {
            @Override
            public void accept(Boolean bool) throws Exception {
                CameraViewModel.this.camera = null;
                Log.i(CameraViewModel.TAG, "closeOpenedCamera success");
            }
        }).doOnError(new Consumer<Throwable>() {
            @Override
            public void accept(Throwable th) throws Exception {
                CameraViewModel.this.camera = null;
                Log.i(CameraViewModel.TAG, "closeOpenedCamera error");
            }
        });
    }

    private void subscribeEvent() {
        RxBus.getDefault().unregister(this);
        RxBus.getDefault().subscribe(this, RxBusTag.INFRAREDLIGHT_EVENT, new RxBus.Callback<String>() {
            @Override
            public void onEvent(String str) {
                if (str.equalsIgnoreCase(DebugKt.DEBUG_PROPERTY_VALUE_AUTO)) {
                    if (CameraViewModel.this.camera != null) {
                        CameraViewModel.this.camera.setInfraredLightMode(true);
                        CameraViewModel.this.camera.changeInfraredLight(false);
                    }
                } else if (str.equalsIgnoreCase("open")) {
                    if (CameraViewModel.this.camera != null) {
                        CameraViewModel.this.camera.setInfraredLightMode(false);
                        CameraViewModel.this.camera.changeInfraredLight(true);
                    }
                } else if (CameraViewModel.this.camera != null) {
                    CameraViewModel.this.camera.setInfraredLightMode(false);
                    CameraViewModel.this.camera.changeInfraredLight(false);
                }
            }
        });
    }

    public void release() {
        Log.i(TAG, "release");
        RxBus.getDefault().unregister(this);
        this.cameraCallBack = null;
        unregisterReceiver();
        AbstractZFYCamera abstractZFYCamera = this.camera;
        if (abstractZFYCamera != null) {
            abstractZFYCamera.closeCamera().doFinally(new Action() {
                @Override
                public  void run() {
                    CameraViewModel.this.camera = null;
                }
            }).subscribe(new SingleObserver<Boolean>() {
                @Override
                public void onError(Throwable th) {
                }

                @Override
                public void onSubscribe(Disposable disposable) {
                }

                @Override
                public void onSuccess(Boolean bool) {
                }
            });
        }
        CompositeDisposable compositeDisposable = this.compositeDisposable;
        if (compositeDisposable != null) {
            compositeDisposable.dispose();
            this.compositeDisposable = null;
        }
    }

    private ZFYCameraCallBack getCameraCallBack() {
        if (this.cameraCallBack == null) {
            this.cameraCallBack = new ZFYCameraCallBack() {
                @Override
                public SurfaceTexture getPreviewSurfaceTexture() {
                    return null;
                }

                @Override
                public void onCameraSwitch() {
                }

                @Override
                public void onCaptureComplete(byte[] bArr, int i) {
                }

                @Override
                public void onRemoteStream(byte[] bArr, long j) {
                }

                @Override
                public void onVideoStream(byte[] bArr, long j) {
                }

                @Override
                public void onError(String str) {
                    Log.e(CameraViewModel.TAG, "onError " + str);
                }

                @Override
                public void cameraStatusChange(int cameraStatusChange) {
                    Log.w(TAG, "cameraStatusChange " + cameraStatusChange);
                    CameraViewModel.this.statueChangePublishSubject.onNext(Integer.valueOf(cameraStatusChange));
                }
            };
        }
        return this.cameraCallBack;
    }

    private void setUpReceiver() {
        if (this.flashLightBroadcastReceiver != null) {
            return;
        }
        Log.i(TAG, "setUpReceiver");
        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction("android.hardware.usb.action.USB_DEVICE_ATTACHED");
        intentFilter.addAction("android.hardware.usb.action.USB_DEVICE_DETACHED");
        getContext().registerReceiver(getFlashLightBroadcastReceiver(), intentFilter);
        this.statueChangePublishSubject.subscribe(new Observer<Integer>() {
            @Override
            public void onComplete() {
            }

            @Override
            public void onNext(Integer num) {
            }

            @Override
            public void onSubscribe(Disposable disposable) {
            }

            @Override
            public void onError(Throwable th) {
                th.printStackTrace();
            }
        });
    }

    private BroadcastReceiver getFlashLightBroadcastReceiver()
    {
        if (this.flashLightBroadcastReceiver == null) {
            this.flashLightBroadcastReceiver = new BroadcastReceiver()
            {
                @Override
                public void onReceive(Context context, Intent intent) {
                    if (intent.getAction() == null) {
                        return;
                    }
                    Log.i(TAG, "" + intent.getAction());
                    if (intent.getAction().equalsIgnoreCase("android.intent.action.gosuncn.zfy.FlashLightEvent")) {
                        return;
                    }
                    if (USBMonitor.ACTION_USB_DEVICE_ATTACHED.equalsIgnoreCase(intent.getAction())) {
                        Log.i(TAG, USBMonitor.ACTION_USB_DEVICE_ATTACHED);
                        UsbDevice usbDevice = intent.getParcelableExtra("device");
                        Log.i(TAG, "USB_DEVICE_ATTACHED ManufacturerName: " + usbDevice.getManufacturerName() + " getProductName " + usbDevice.getProductName() + " getSerialNumber " + usbDevice.getSerialNumber() + " getSerialNumber " + usbDevice.getSerialNumber());
                        if (ZFYUsbDeviceHelper.checkIsUVCUsbDevice(usbDevice))
                        {
                            Log.i(TAG, "checkIsUVCIn");
                            ZFYStatus.getInstance().setUVCCameraIn(true);
                            if (CameraViewModel.this.cameraCallBack != null)
                            {
                                Log.i(TAG, "onCameraSwitch");
                                CameraViewModel.this.cameraCallBack.onCameraSwitch();
                            }
                        }
                    } else if ("android.hardware.usb.action.USB_DEVICE_DETACHED".equalsIgnoreCase(intent.getAction()))
                    {
                        Log.i(TAG, "android.hardware.usb.action.USB_DEVICE_DETACHED");
                        UsbDevice usbDevice2 = (UsbDevice) intent.getParcelableExtra("device");
                        Log.i(TAG, "USB_DEVICE_DETACHED ManufacturerName: " + usbDevice2.getManufacturerName() + " getProductName " + usbDevice2.getProductName() + " getSerialNumber " + usbDevice2.getSerialNumber() + " getSerialNumber " + usbDevice2.getSerialNumber());
                        if (ZFYUsbDeviceHelper.checkIsUVCUsbDevice(usbDevice2) && (CameraViewModel.this.camera instanceof UVCCameraHelper)) {
                            Log.i(TAG, "onCameraSwitch UVCCameraHelper");
                            if (CameraViewModel.this.cameraCallBack != null) {
                                CameraViewModel.this.cameraCallBack.onCameraSwitch();
                            }

                            try {
                                AudioManager audioManager = (AudioManager) CameraViewModel.this.getContext().getSystemService(Context.AUDIO_SERVICE);
                                if (audioManager != null) {
                                    Log.i(TAG, "AudioManager reset");
                                    audioManager.setMode(AudioManager.MODE_NORMAL);
                                    audioManager.setSpeakerphoneOn(true);
                                    audioManager.setStreamMute(3, false);
                                    audioManager.setStreamMute(5, false);
                                    audioManager.setStreamMute(0, false);
                                }
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }
                    }
                }
            };
        }
        return this.flashLightBroadcastReceiver;
    }

    private void unregisterReceiver() {
        Log.i(TAG, "unregisterReceiver");
    }

    public void updatePreviewStatus() {
        AbstractZFYCamera abstractZFYCamera = this.camera;
        if (abstractZFYCamera != null) {
            abstractZFYCamera.updatePreviewStatus();
        }
    }

    public void leaveAction() {
        if (this.flashLightBroadcastReceiver != null) {
            getContext().unregisterReceiver(this.flashLightBroadcastReceiver);
            this.flashLightBroadcastReceiver = null;
        }
    }

    public Single<Boolean> onPauseAction() {
        AbstractZFYCamera abstractZFYCamera = this.camera;
        if (abstractZFYCamera == null) {
            return Single.just(Boolean.TRUE);
        }
        return abstractZFYCamera.closeCamera().doFinally(new Action() {
            @Override
            public  void run() {
                CameraViewModel.this.camera = null;
            }
        }).flatMap(new Function() {
            @Override
            public  Object apply(Object obj) {
                return checkTorchOpen();
            }
        });
    }


    private Single<Boolean> checkTorchOpen() {
        if (isTorchOpen()) {
            CameraManager cameraManager = (CameraManager) getContext().getSystemService(Context.CAMERA_SERVICE);
            try {
                String[] cameraIdList = cameraManager.getCameraIdList();
                if (cameraIdList != null && cameraIdList.length > 0) {
                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                        cameraManager.setTorchMode(cameraIdList[0], true);
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return Single.just(Boolean.TRUE);
    }

    public void updateCameraStream(boolean isPreviewing, boolean isRecording, boolean isRemoting) {
        if (this.camera != null) {
            Log.i(TAG, "updateCameraStream: " + this.camera.getLocalizedName());
            this.camera.updateCameraStream(isPreviewing, isRecording, isRemoting);
            return;
        }
        Log.w(TAG, "updateCameraStream camera == null");
    }

    public synchronized Single<Boolean> startPreviewStream() {
        if (this.camera != null) {
            Log.i(TAG, "startPreviewStream");
            return this.camera.startPreviewStream();
        }
        Log.w(TAG, "startPreviewStream camera == null");
        return Single.just(Boolean.TRUE);
    }

    public String getLocalizedName() {
        AbstractZFYCamera abstractZFYCamera = this.camera;
        if (abstractZFYCamera == null) {
            return getContext().getString(R.string.unknow);
        }
        return abstractZFYCamera.getLocalizedName();
    }

    public void capture() {
        if (this.camera == null || this.captureLock.get()) {
            return;
        }
        this.captureLock.set(true);
        this.camera.capture().doFinally(new Action() {
            @Override
            public  void run() {
                CameraViewModel.this.captureLock.set(false);
            }
        }).subscribe(new SingleObserver<Boolean>() {
            @Override
            public void onError(Throwable th) {
            }

            @Override
            public void onSubscribe(Disposable disposable) {
            }

            @Override
            public void onSuccess(Boolean bool) {
            }
        });
    }

    public boolean isLocked() {
        if (this.camera == null) {
            return false;
        }
        return this.camera.isLocked();
    }

    public ZFYCameraParameters getCameraParameters() {
        if (this.camera == null) {
            return null;
        }
        return this.camera.getParameters();
    }

    public float getCurrentZoom() {
        if (this.camera == null) {
            return 1.0f;
        }
        return this.camera.getCurrentZoom();
    }

    public float getMaxZoomValue() {
        if (this.camera == null) {
            return 1.0f;
        }
        return this.camera.getMaxZoomValue();
    }

    public boolean setCurrentZoom(float f) {
        if (this.camera != null && f <= this.camera.getMaxZoomValue() && f >= 1.0f) {
            this.camera.setCurrentZoom(f);
            return true;
        }
        return false;
    }

    public boolean isOpenedCamera() {
        if (this.camera == null) {
            Log.w(TAG, "camera == null");
        }
        return this.camera != null;
    }

    public boolean isTorchOpen() {
        return true;
    }

    public Observable<ZFYCameraParameters> changePPI() {
        if (this.camera == null) {
            return Observable.error(new Throwable(getContext().getString(R.string.camera_error_not_open)));
        }
        if (isLocked()) {
            return Observable.error(new Throwable(getContext().getString(R.string.please_wait)));
        }
        return this.camera.changePPI();
    }

    public void setWideAngleDistortion(boolean wideAngleDistortion) {
        if (this.camera != null) {
            this.camera.setWideAngleDistortion(wideAngleDistortion);
        }
    }

    public void switchInfraredLight() {
        if (this.camera == null) {
            return;
        }
        this.camera.switchInfraredLight();
    }

    public boolean isInfraredLightOpen() {
        if (this.camera != null) {
            return this.camera.isInfraredLightOpen();
        }
        return false;
    }

    public Single<Float> cameraZoom() {
        float f = this.targetZoom + 1.0f;
        if (this.camera == null) {
            return Single.error(new Throwable(getString(R.string.camera_error_not_open)));
        }
        if (f > this.camera.getMaxZoomValue()) {
            return Single.error(new Throwable(getString(R.string.preview_can_not_zoom)));
        }
        this.targetZoom = f;
        if (this.zoomLock.get()) {
            return Single.just(Float.valueOf(this.targetZoom));
        }
        this.zoomLock.set(true);
        Single.just(Float.valueOf(this.targetZoom)).doOnSuccess(new Consumer<Float>() {
            @Override
            public void accept(Float f2) throws Exception {
                CameraViewModel.this.camera.setCurrentZoom(f2.floatValue());
            }
        }).delay(1L, TimeUnit.SECONDS).doFinally(new Action() {
            @Override
            public void run() throws Exception {
                CameraViewModel.this.zoomLock.set(false);
            }
        }).subscribe(new SingleObserver<Float>() {
            @Override
            public void onSubscribe(Disposable disposable) {
            }

            @Override
            public void onSuccess(Float f2) {
                if (CameraViewModel.this.targetZoom != f2.floatValue()) {
                    CameraViewModel.this.camera.setCurrentZoom(CameraViewModel.this.targetZoom);
                }
            }

            @Override
            public void onError(Throwable th) {
                CameraViewModel cameraViewModel = CameraViewModel.this;
                cameraViewModel.targetZoom = cameraViewModel.getCurrentZoom();
            }
        });
        return Single.just(Float.valueOf(this.targetZoom));
    }

    public Single<Float> cameraZoomPercent(float f)
    {
        AbstractZFYCamera abstractZFYCamera = this.camera;
        if (abstractZFYCamera == null) {
            return Single.error(new Throwable(getString(R.string.camera_error_not_open)));
        }
        this.targetZoom = ((abstractZFYCamera.getMaxZoomValue() - 1.0f) * f) + 1.0f;
        if (this.zoomLock.get()) {
            return Single.just(Float.valueOf(this.targetZoom));
        }
        this.zoomLock.set(true);
        Single.just(Float.valueOf(this.targetZoom)).doOnSuccess(new Consumer() {
            @Override
            public  void accept(Object obj) {
                CameraViewModel.this.camera.setCurrentZoom(((Float) obj).floatValue());
            }
        }).delay(500L, TimeUnit.MILLISECONDS).doFinally(new Action() {
            @Override
            public  void run() {
                CameraViewModel.this.zoomLock.set(false);
            }
        }).subscribe(new SingleObserver<Float>() {
            @Override
            public void onSubscribe(Disposable disposable) {
            }

            @Override
            public void onSuccess(Float f2) {
                if (CameraViewModel.this.targetZoom != f2.floatValue()) {
                    CameraViewModel.this.camera.setCurrentZoom(CameraViewModel.this.targetZoom);
                }
            }

            @Override
            public void onError(Throwable th) {
                CameraViewModel cameraViewModel = CameraViewModel.this;
                cameraViewModel.targetZoom = cameraViewModel.getCurrentZoom();
            }
        });
        return Single.just(Float.valueOf(this.targetZoom));
    }



    public Single<Float> cameraSmaller() {
        if (this.camera == null) {
            return Single.error(new Throwable(getString(R.string.camera_error_not_open)));
        }
        float f = this.targetZoom - 1.0f;
        Log.i(TAG, "targetZoom " + this.targetZoom + " getCurrentZoom" + this.camera.getCurrentZoom());
        if (f < 1.0f) {
            return Single.error(new Throwable(getString(R.string.preview_can_not_smaller)));
        }
        this.targetZoom = f;
        if (this.zoomLock.get()) {
            return Single.just(Float.valueOf(this.targetZoom));
        }
        this.zoomLock.set(true);
        Single.just(Float.valueOf(this.targetZoom)).doOnSuccess(new Consumer<Float>() {
            @Override
            public void accept(Float f2) throws Exception {
                CameraViewModel.this.camera.setCurrentZoom(f2.floatValue());
            }
        }).delay(3L, TimeUnit.SECONDS).doFinally(new Action() {
            @Override
            public void run() throws Exception {
                CameraViewModel.this.zoomLock.set(false);
            }
        }).subscribe(new SingleObserver<Float>() {
            @Override
            public void onSubscribe(Disposable disposable) {
            }

            @Override
            public void onSuccess(Float f2) {
                if (CameraViewModel.this.targetZoom != f2.floatValue()) {
                    CameraViewModel.this.camera.setCurrentZoom(CameraViewModel.this.targetZoom);
                }
            }

            @Override
            public void onError(Throwable th) {
                CameraViewModel cameraViewModel = CameraViewModel.this;
                cameraViewModel.targetZoom = cameraViewModel.getCurrentZoom();
            }
        });
        return Single.just(Float.valueOf(this.targetZoom));
    }

    private String getString(int i) {
        return getContext().getString(i);
    }

    public void addDisposable(Disposable disposable) {
        if (this.compositeDisposable == null) {
            this.compositeDisposable = new CompositeDisposable();
        }
        this.compositeDisposable.add(disposable);
    }
}
